{% if operation.CanRequestBlobs and response.IsFile -%}
{%     if Framework.IsAngularJS -%}
const contentDisposition = response.headers ? response.headers("content-disposition") : undefined;
{%     elseif Framework.IsAxios -%}
const contentDisposition = response.headers ? response.headers["content-disposition"] : undefined;
{%     else -%}
const contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
{%     endif -%}
const fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
const fileName = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
{%     if operation.WrapResponse -%}
{%         if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}<any>responseBlob{% else %}<any>response.blob(){% endif %}, status: status, headers: _headers }));
{%         elseif Framework.IsAngularJS -%}
return this.q.resolve(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, status: status, data: new Blob([response.data]), headers: _headers }));
{%         elseif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, status: status, data: new Blob([response.data]), headers: _headers }));
{%         else -%}
return response.blob().then(blob => { return new {{ operation.ResponseClass }}(status, _headers, { fileName: fileName, data: blob, status: status, headers: _headers }); });
{%         endif -%}
{%     else -%}
{%         if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}({ fileName: fileName, data: {% if Framework.Angular.UseHttpClient %}<any>responseBlob{% else %}<any>response.blob(){% endif %}, status: status, headers: _headers });
{%         elseif Framework.IsAngularJS -%}
return this.q.resolve({ fileName: fileName, status: status, data: new Blob([response.data]), headers: _headers });
{%         elseif Framework.IsAxios -%}
return Promise.resolve({ fileName: fileName, status: status, data: response.data as Blob, headers: _headers });
{%         else -%}
return response.blob().then(blob => { return { fileName: fileName, data: blob, status: status, headers: _headers }; });
{%         endif -%}
{%     endif -%}
{% else -%}
{% template Client.ProcessResponse.ReadBodyStart %}
{%     if response.HasType -%}
let result{{ response.StatusCode }}: any = null;
{%         if Framework.IsAxios -%}
let resultData{{ response.StatusCode }}  = _responseText;
{%             if response.UseDtoClass -%}
{{ response.DataConversionCode }}
{%             else -%}
result{{ response.StatusCode }} = JSON.parse(resultData{{ response.StatusCode }});
{%             endif -%}
{%         else -%}
{%              if response.UseDtoClass or response.IsDateOrDateTime -%}
let resultData{{ response.StatusCode }} = _responseText === "" ? null : {% if operation.HandleReferences %}jsonParse{% else %}JSON.parse{% endif %}(_responseText, this.jsonParseReviver);
{{ response.DataConversionCode }}
{%              else -%}
result{{ response.StatusCode }} = _responseText === "" ? null : <{{ response.Type }}>{% if operation.HandleReferences %}jsonParse{% else %}JSON.parse{% endif %}(_responseText, this.jsonParseReviver);
{%              endif -%}
{%         endif -%}
{%         if response.IsSuccess -%}
{%             if operation.WrapResponse -%}
{%                 if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}(new {{ operation.ResponseClass }}(status, _headers, result{{ response.StatusCode }}));
{%                 elseif Framework.IsAngularJS -%}
return this.q.resolve(new {{ operation.ResponseClass }}(status, _headers, result{{ response.StatusCode }}));
{%                 elseif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResultType }}(status, _headers, result{{ response.StatusCode }}));
{%                 else -%}
return new {{ operation.ResponseClass }}(status, _headers, result{{ response.StatusCode }});
{%                 endif -%}
{%             else -%}
{%                 if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}(result{{ response.StatusCode }});
{%                 elseif Framework.IsAngularJS -%}
return this.q.resolve(result{{ response.StatusCode }});
{%                 else -%}
return result{{ response.StatusCode }};
{%                 endif -%}
{%             endif -%}
{%         else -%}
return throwException({% if Framework.IsAngularJS %}this.q, {% endif %}"{{ response.ExceptionDescription }}", status, _responseText, _headers, result{{ response.StatusCode }});
{%         endif -%}
{%     elseif response.IsSuccess -%}
{%         if operation.WrapResponse -%}
{%             if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
{%             elseif Framework.IsAngularJS -%}
return this.q.resolve<{{ operation.ResultType }}>(new {{ operation.ResponseClass }}(status, _headers, <any>null));
{%             elseif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(new {{ operation.ResultType }}(status, _headers, <any>null));
{%             else -%}
return new {{ operation.ResponseClass }}(status, _headers, <any>null);
{%             endif -%}
{%         else -%}
{%             if Framework.IsAngular -%}
return {{ Framework.RxJs.ObservableOfMethod }}<{{ operation.ResultType }}>(<any>null);
{%             elseif Framework.IsAngularJS -%}
return this.q.resolve<{{ operation.ResultType }}>(<any>null);
{%             elseif Framework.IsAxios -%}
return Promise.resolve<{{ operation.ResultType }}>(<any>null);
{%             else -%}
return{% if operation.HasResultType %} null{% endif %};
{%             endif -%}
{%         endif -%}
{%     else -%}
return throwException({% if Framework.IsAngularJS %}this.q, {% endif %}"{{ response.ExceptionDescription }}", status, _responseText, _headers);
{%     endif -%}
{% template Client.ProcessResponse.ReadBodyEnd %}
{% endif -%}
